home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJLSR106.ARJ / BCOPY.CC < prev    next >
C/C++ Source or Header  |  1992-03-24  |  700b  |  41 lines

  1. #if defined(USG) && !defined(hpux)
  2.  
  3. /* SysV version of bcopy from Eric Newton */
  4.  
  5. void libgxx_bcopy (void *source, void *dest, int count)
  6. {
  7.   /* No overlapping */
  8.   if (source == dest)
  9.     return;
  10.   else if (source < dest && source+count > dest)
  11.   {
  12.      memcpy(dest, source, count);
  13.      return;
  14.   }
  15.   else if (dest < source && dest+count < source)
  16.   {
  17.      memcpy(dest, source, count);
  18.      return;
  19.   }
  20.   else
  21.   {
  22.     char* s = (char*) source;
  23.     char* d = (char*) dest;
  24.     if (s > d)
  25.     {
  26.       while (count-- > 0) *d++ = *s++;
  27.       return;
  28.     }
  29.     else
  30.     {
  31.       count--;
  32.       d = &d[count];
  33.       s = &s[count];
  34.       while (count-- >= 0) *d-- = *s--;
  35.       return;
  36.     }
  37.   }
  38. }
  39.  
  40. #endif
  41.